package com.qingcheng.consumer;

import com.qingcheng.service.index.IndexService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;


//商品上架,监听队列接受到消息后,将该商品的生成索引并存储到elasticsearch的数据中
public class IndexAddConsumer implements MessageListener {

    @Autowired
    private IndexService indexService;

    //商品上架,向elasticsearch中添加索引
    public void onMessage(Message message) {
        String spuId = new String(message.getBody());
        System.err.println("-------------------AAAAAAA:"+spuId);
        indexService.addIndex(spuId);
    }

}
